package com.lkd.handler;

import com.google.common.base.Strings;
import com.lkd.business.MsgHandler;
import com.lkd.config.TopicConfig;
import com.lkd.contract.VendoutContract;
import com.lkd.emq.Topic;
import com.lkd.service.ChannelService;
import com.lkd.service.VendingMachineService;
import com.lkd.utils.JsonUtil;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author Administrator
 */
@Topic(TopicConfig.VMS_VENDOUT_TOPIC)
public class VendoutMsgHandler implements MsgHandler {
    @Resource
    private ChannelService channelService;

    @Override
    public void process(String jsonMsg) throws IOException {
        VendoutContract contract = JsonUtil.getByJson(jsonMsg, VendoutContract.class);
        //处理契约
        if(Strings.isNullOrEmpty(contract.getInnerCode())){
            return;
        }
        //更新库存
        channelService.updateStock(contract);
    }
}
